package cn.tedu.rediscluster;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.connection.RedisClusterConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;

import javax.annotation.PostConstruct;

@SpringBootApplication
public class RedisClusterApplication {
    @Autowired
    private RedisConnectionFactory f;

    public static void main(String[] args) {
        SpringApplication.run(RedisClusterApplication.class, args);
    }

    @PostConstruct
    public void test() {
        RedisClusterConnection c = f.getClusterConnection();
        for (int i = 0; i < 100; i++) {
            byte[] k = ("k" + i).getBytes();
            byte[] v = ("v" + i).getBytes();
            c.set(k, v);
        }
    }
}
